home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / x / qdisplay.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-10  |  15.4 KB  |  528 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    This is part of the X user-interface for the WAIS software.  Do with it
  6.    as you please.
  7.  
  8.    jonathan@Think.COM
  9.  */
  10.  
  11. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  12.  
  13.  
  14. #ifndef lint
  15. static char *RCSid = "$Header: /usr/local/ls6/src+data/src/freeWAIS-sf/x/RCS/qdisplay.c,v 1.4 1995/01/10 17:06:47 pfeifer Exp $";
  16. #endif
  17.  
  18. #include "xwais.h"
  19. #include "cursor.h"
  20. #include "myAsciiSink.h"
  21. #include "myAsciiSrc.h"
  22. #include "xwaisq.bit"
  23.  
  24. void SetqIcon(parent)
  25. Widget parent;
  26. {
  27.   Arg args[1];
  28.   Pixmap icon_pixmap = None;
  29.  
  30.   XtSetArg (args[ZERO], XtNiconPixmap, &icon_pixmap);
  31.   XtGetValues(parent, args, ONE);
  32.   if (icon_pixmap == None) {
  33.     XtSetArg(args[ZERO], XtNiconPixmap, 
  34.          XCreateBitmapFromData(XtDisplay(parent),
  35.                    XtScreen(parent)->root,
  36.                    xwaisq_bits, xwaisq_width, xwaisq_height));
  37.     XtSetValues (parent, args, ONE);
  38.   }
  39. }
  40.  
  41. Widget
  42. MakeQuestionPane(parent, question)
  43. Widget parent;
  44. XQuestion question;
  45. {
  46.   Widget frame, stringlabelwid, button, view;
  47.   static   AsciiSinkObject sink = NULL;
  48.   static String
  49.     name = "";
  50.   Arg args[THREE];
  51.   static String items[] = {NULL};
  52.   Question q = question->q;
  53.  
  54.   question->window->shell = parent;
  55.   frame =
  56.     XtCreateManagedWidget("questionpopupform", formWidgetClass,
  57.               question->window->shell, NULL, ZERO);
  58.  
  59.   SetqIcon(question->window->shell);
  60.  
  61.   stringlabelwid =
  62.     MakeLabel(frame, "keywordlabel", "Tell me about:", NULL, NULL);
  63.  
  64. #ifdef MOTIF
  65.   question->window->keywordwid =
  66.     MakeStringBox(frame, "keywords", "", stringlabelwid, NULL);
  67. #else
  68.   XtSetArg(args[ZERO], XtNeditType, XawtextEdit);
  69.   XtSetArg(args[ONE], XtNstring, "");
  70.   XtSetArg(args[TWO], XtNfromVert, stringlabelwid);
  71.  
  72.   question->window->keywordwid =
  73.     XtCreateManagedWidget("keywords", asciiTextWidgetClass, frame, args, THREE);
  74.  
  75.   if (sink == NULL) {
  76.     sink = (AsciiSinkObject)
  77.       XtCreateWidget("sink", myasciiSinkObjectClass, 
  78.              question->window->keywordwid, NULL, ZERO);
  79.  
  80.     XtSetArg(args[ZERO], XtNtextSink, sink);
  81.     XtSetValues(question->window->keywordwid, args, ONE);
  82.   }
  83. #endif
  84.  
  85.   searchButton = MakeCommandButton(frame, "wsearch", DoSearch,
  86.                  stringlabelwid, question->window->keywordwid, NULL);
  87.   stringlabelwid =
  88.     MakeLabel(frame, "qsourcelabel", "In Sources:",
  89.           NULL, NULL);
  90.  
  91.   XtSetArg (args[ZERO], XtNallowVert, VERTVAL);
  92.  
  93.   view = XtCreateManagedWidget ("sview", viewportWidgetClass,
  94.                 frame, args, ONE);
  95.  
  96.   question->window->Sources =
  97.     MakeScrollList(view, "questionsource", question->Source_Items,
  98.            EditQuestionSource, NULL, NULL);
  99.  
  100. #ifndef MOTIF
  101.   XtAddCallback(question->window->Sources->ListWidget, XtNcallback,
  102.         SensitizeDelSource, NULL);
  103. #endif
  104.  
  105.   stringlabelwid =
  106.     MakeLabel(frame, "qdoclabel", "Similar to:",
  107.           question->window->keywordwid, NULL);
  108.  
  109.   view = XtCreateManagedWidget ("dview", viewportWidgetClass,
  110.                 frame, args, ONE);
  111.  
  112.   question->window->RelevantDocuments = 
  113.     MakeScrollList(view, "questiondoc", question->Relevant_Items,
  114.            ViewRelevant, NULL, NULL);
  115.  
  116. #ifndef MOTIF
  117.   XtAddCallback(question->window->RelevantDocuments->ListWidget, XtNcallback,
  118.         SensitizeDelDoc, NULL);
  119. #endif
  120.  
  121.   addSourceButton = button =
  122.     MakeCommandButton(frame, "qaddsource", PopupSourceMenu,
  123.               view, NULL, NULL);
  124.   delSourceButton = button =
  125.     MakeCommandButton(frame, "qdeletesource", DeleteQuestionSource,
  126.               view, button, NULL);
  127.   XtSetSensitive(button, SENSVAL);
  128.  
  129.   addDocButton = button =
  130.     MakeCommandButton(frame, "qadddoc", AddResponseToQuestion,
  131.               view, NULL, NULL);
  132.   XtSetSensitive(button, SENSVAL);
  133.  
  134.   delDocButton = button =
  135.     MakeCommandButton(frame, "qdeletedoc", DeleteQuestionDoc,
  136.               view, button, NULL);
  137.  
  138.   XtSetSensitive(button, SENSVAL);
  139.  
  140.   stringlabelwid =
  141.     MakeLabel(frame, "qreslabel", "Resulting",   /* Added space after g */
  142.           NULL, NULL);
  143.  
  144.   stringlabelwid =
  145.     MakeLabel(frame, "qreslabel1", "documents:",
  146.           stringlabelwid, NULL);
  147.  
  148.   viewbutton = button = 
  149.     MakeCommandButton(frame, "view", ViewResponse,
  150.               stringlabelwid, NULL, NULL);
  151.  
  152.   saveAsButton = button =
  153.     MakeCommandButton(frame, "qsave", ViewResponse,
  154.               button, NULL, NULL);
  155.  
  156.   abortButton = button =
  157.     MakeCommandButton(frame, "Abort", Abort,
  158.               button, NULL, NULL);
  159.  
  160.   button =
  161.     MakeCommandButton(frame, "Prefs", Prefs,
  162.               button, NULL, NULL);
  163.  
  164.   helpButton = button =
  165.     MakeCommandButton(frame, "help", XwaisHelp,
  166.               button, NULL, NULL);
  167.   doneButton = button =
  168.     MakeCommandButton(frame, "qdone", CloseQuestionEdit,
  169.               button, NULL, NULL);
  170.  
  171.   view = XtCreateManagedWidget ("rview", viewportWidgetClass,
  172.                 frame, args, ONE);
  173.  
  174.   question->window->ResultDocuments = 
  175.     MakeScrollList(view, "questionresults", question->Result_Items,
  176.            ViewResponse, NULL, NULL);
  177.  
  178. #ifndef MOTIF
  179.   XtAddCallback(question->window->ResultDocuments->ListWidget,XtNcallback,
  180.         SensitizeAddDoc,(XtPointer)0);
  181. #endif
  182.  
  183.   stringlabelwid =
  184.     MakeLabel(frame, "statuslabel", "Status:",
  185.           NULL, NULL);
  186.  
  187.   XtSetArg(args[ZERO], XtNeditType, XawtextEdit);
  188.  
  189.   question->window->StatusWindow =
  190.     XtCreateManagedWidget("statusWindow", asciiTextWidgetClass,
  191.               frame, args, ONE);
  192.   XtSetKeyboardFocus(frame, question->window->keywordwid);
  193.   return(question->window->shell);
  194. }
  195.  
  196. Widget
  197. MakeTextPopup(parent, t, name)
  198. Widget parent;
  199. Textbuff t;
  200. char *name;
  201. {
  202.   Widget frame, button;
  203.   Arg args[TWO];
  204.   static String items[] = {NULL};
  205.   AsciiSinkObject sink;
  206.   AsciiSourceObject src;
  207.  
  208.   XtSetArg(args[ZERO], XtNtitle, name);
  209.   XtSetArg(args[ONE], XtNiconName, name);
  210.   t->shell = XtCreatePopupShell("textpopup", applicationShellWidgetClass,
  211.                 parent, args, TWO);
  212.   frame =
  213.     XtCreateManagedWidget("questionpopupform", formWidgetClass,
  214.               t->shell, NULL, ZERO);
  215.  
  216.   XtSetArg(args[ZERO], XtNeditType, XawtextRead);
  217.   t->textwindow =
  218.     XtCreateManagedWidget("textWindow", asciiTextWidgetClass, frame, args, ONE);
  219.  
  220.   sink = (AsciiSinkObject)
  221.     XtCreateWidget("sink", myasciiSinkObjectClass, 
  222.            t->textwindow, NULL, ZERO);
  223.  
  224.   src = (AsciiSrcObject)
  225.     XtCreateWidget("sink", myasciiSrcObjectClass, 
  226.            t->textwindow, NULL, ZERO);
  227.  
  228.   XtSetArg(args[ZERO], XtNtextSink, sink);
  229.   XtSetArg(args[ONE], XtNtextSource, src);
  230.   XtSetValues(t->textwindow, args, TWO);
  231.  
  232.   button = MakeCommandButton(frame, "findKeywords", showKeyword,
  233.                  t->textwindow, NULL, NULL);
  234.   button = MakeCommandButton(frame, "addSection",addSection,
  235.                  t->textwindow, button, NULL);
  236.   button = MakeCommandButton(frame, "showNext", showNext,
  237.                  t->textwindow, button, (XtPointer)t);
  238.   button = MakeCommandButton(frame, "showPrevious", showPrevious,
  239.                  t->textwindow, button, (XtPointer)t);
  240.   button = MakeCommandButton(frame, "filesave", SaveText,
  241.                  t->textwindow, button, NULL);
  242.   button = MakeCommandButton(frame, "tdone", EndText,
  243.                  t->textwindow, button, (XtPointer)t);
  244.  
  245.   MakeLabel(frame, "textstatuslabel", "Status:", button, NULL);
  246.  
  247.   XtSetArg(args[ZERO], XtNeditType, XawtextEdit);
  248.  
  249.   t->status =
  250.     XtCreateManagedWidget("textStatus", asciiTextWidgetClass, frame, args, ONE);
  251.  
  252.   SettIcon(t->shell);
  253.  
  254.   XtPopup(t->shell, XtGrabNone);
  255.  
  256.   return t->textwindow;
  257. }
  258.  
  259. QuestionWindow
  260. MakeQuestionForm(question)
  261. XQuestion question;
  262. {
  263.   QuestionWindow result;
  264.  
  265.   if((result = (QuestionWindow) s_malloc(sizeof(_QuestionWindow))) == NULL) {
  266.     XwaisPrintf("Unable to allocate space for new window.\n");
  267.     return(NULL);
  268.   }
  269.  
  270.   question->window = result;
  271.   question->q->CurrentSource = NO_ITEM_SELECTED;
  272.   question->q->CurrentRelDoc = NO_ITEM_SELECTED;
  273.   question->q->CurrentResDoc = NO_ITEM_SELECTED;
  274.  
  275.   result->shell = MakeQuestionPane(top, question);
  276.  
  277.   ReplaceText(result->keywordwid, question->q->keywords);
  278.  
  279.   return(result);
  280. }
  281.  
  282. Widget
  283. MakeSourcePopup(parent)
  284. Widget parent;
  285. {
  286.   Arg args[THREE];
  287.  
  288.   Widget shell, frame, labelwid, stringlabelwid, button, tmp;
  289.   WidgetClass wclass;
  290.   static String
  291.     namestring,
  292.   serverstring,
  293.   servicestring,
  294.   dbstring,
  295.   cost, units,
  296.   maintainer,
  297.   description;
  298.   int CurrentSource;
  299.   static   AsciiSinkObject sink = NULL;
  300.  
  301.   namestring = "default";
  302.   serverstring = "localhost";
  303.   servicestring = "8000";
  304.   dbstring = "";
  305.   cost = "";
  306.   units = "";
  307.   maintainer = "";
  308.   description = "";
  309.  
  310.   shell = XtCreatePopupShell("sourcepopup", applicationShellWidgetClass,
  311.                  parent, NULL, ZERO);
  312.   frame = XtCreateManagedWidget("sourcepopupform", formWidgetClass,
  313.                 shell, NULL, ZERO);
  314.  
  315.   stringlabelwid = MakeLabel(frame, "sourcenamelabel", "       Name:", NULL, NULL);
  316.   tmp = snamewid = MakeStringBox(frame, "sourcename", namestring, NULL, stringlabelwid);
  317.  
  318.   stringlabelwid = MakeLabel(frame, "serverlabel",     "     Server:", tmp, NULL);
  319.   tmp = serverwid = MakeStringBox(frame, "server", serverstring, tmp, stringlabelwid);
  320.  
  321.   stringlabelwid = MakeLabel(frame, "servicelabel", "    Service:", tmp, NULL);
  322.   tmp = servicewid = MakeStringBox(frame, "service", serverstring, tmp, stringlabelwid);
  323.  
  324.   stringlabelwid = MakeLabel(frame, "dblabel",      "   Database:", tmp, NULL);
  325.   tmp = dbwid = MakeStringBox(frame, "database", dbstring, tmp, stringlabelwid);
  326.  
  327.   stringlabelwid = MakeLabel(frame, "costlabel",    "       Cost:", tmp, NULL);
  328.   tmp = costwid = MakeStringBox(frame, "cost", cost, tmp, stringlabelwid);
  329.  
  330.   stringlabelwid = MakeLabel(frame, "unitlabel",    "      Units:", tmp, NULL);
  331.   tmp = unitwid = MakeStringBox(frame, "costunit", units, tmp, stringlabelwid);
  332.  
  333.   stringlabelwid = MakeLabel(frame, "maintlabel",   " Maintainer:", tmp, NULL);
  334.   tmp = maintainerwid = MakeStringBox(frame, "maintainer", maintainer, tmp, stringlabelwid);
  335.  
  336.   stringlabelwid = MakeLabel(frame, "desclabel",    "Description:", tmp, NULL);
  337.  
  338.   XtSetArg(args[ZERO], XtNeditType, XawtextEdit);
  339.   XtSetArg(args[ONE], XtNstring, description);
  340.   XtSetArg(args[TWO], XtNfromVert, stringlabelwid);
  341.  
  342.   tmp = descwid = 
  343.     XtCreateManagedWidget("description", asciiTextWidgetClass, frame, args, THREE);
  344.  
  345.   if (sink == NULL) {
  346.     sink = (AsciiSinkObject)
  347.       XtCreateWidget("sink", myasciiSinkObjectClass, 
  348.              descwid, NULL, ZERO);
  349.  
  350.     XtSetArg(args[ZERO], XtNtextSink, sink);
  351.     XtSetValues(descwid, args, ONE);
  352.   }
  353.  
  354.   button = MakeCommandButton(frame, "sdone", DoSSave, tmp, NULL, NULL);
  355.   MakeCommandButton(frame, "cancel", CancelSourceEdit, tmp, button, NULL);
  356.  
  357.   return shell;
  358. }
  359.  
  360. Widget
  361. MakePrefPopup(parent)
  362. Widget parent;
  363. {
  364.   Widget shell, frame, labelwid, stringlabelwid, button;
  365.   WidgetClass wclass;
  366.   static String maxDocs = "", sourcepath = "", filters = "";
  367.   
  368.   shell = XtCreatePopupShell("prefpopup", applicationShellWidgetClass,
  369.                  parent, NULL, ZERO);
  370.   frame = XtCreateManagedWidget("prefpopupform", formWidgetClass,
  371.                 shell, NULL, ZERO);
  372.  
  373.   labelwid = MakeLabel(frame, "preflabel", "Set Preferences", NULL, NULL);
  374.  
  375.   stringlabelwid = MakeLabel(frame, "prefmaxdoclabel",
  376.                  "   Maximum Results:", labelwid, NULL);
  377.   maxdocwid = MakeStringBox(frame, "maxdoc", maxDocs, labelwid, stringlabelwid);
  378.  
  379.   stringlabelwid = MakeLabel(frame, "sourcepathlabel",    
  380.                  "Source Search Path:", maxdocwid, NULL);
  381.   sourcepathwid = MakeStringBox(frame, "sourcepath", sourcepath, maxdocwid, stringlabelwid);
  382.  
  383.   stringlabelwid = MakeLabel(frame, "filterlabel",    
  384.                  "           Filters:", sourcepathwid, NULL);
  385.   filterwid = MakeStringBox(frame, "filters", filters, sourcepathwid, stringlabelwid);
  386.  
  387.   button = MakeCommandButton(frame, "pdone", DoPSave, filterwid, NULL, NULL);
  388.   MakeCommandButton(frame, "pcancel", DontPSave, filterwid, button, NULL);
  389.  
  390.   return shell;
  391. }
  392.  
  393. ScrollList
  394. MakeSourceFrame(parent)
  395. Widget parent;
  396. {
  397.   Widget frame, labelwid, button, view;
  398.   ScrollList result;
  399.   Arg args[TWO];
  400.  
  401.   XtSetArg(args[ZERO], XtNtitle, "Sources");
  402.   XtSetArg(args[ONE], XtNiconName, "Sources");
  403.   sshell = XtCreatePopupShell("sourcepane", transientShellWidgetClass, 
  404.                   parent, args, TWO);
  405.   frame = XtCreateManagedWidget("sources", formWidgetClass, sshell, NULL, ZERO);
  406.  
  407.   XtSetArg (args[ZERO], XtNallowVert, VERTVAL);
  408.  
  409.   view = XtCreateManagedWidget ("ssview", viewportWidgetClass,
  410.                 frame, args, ONE);
  411.  
  412.   result =
  413.     MakeScrollList(view, "sourceWindow", Source_items, 
  414.            AddSourceToQuestion, NULL, NULL);
  415.  
  416.   button = MakeCommandButton(frame, "qsadd", AddSourceToQuestion,
  417.                  view, NULL, NULL);
  418.   return result;
  419. }
  420.  
  421. ScrollList
  422. MakeTypeFrame(parent)
  423. Widget parent;
  424. {
  425.   Widget frame, labelwid, button, view;
  426.   ScrollList result;
  427.   Arg args[TWO];
  428.  
  429.   XtSetArg(args[ZERO], XtNtitle, "Types");
  430.   XtSetArg(args[ONE], XtNiconName, "Types");
  431.   typeshell = XtCreatePopupShell("typepane", transientShellWidgetClass, 
  432.                   parent, args, TWO);
  433.   frame = XtCreateManagedWidget("types", formWidgetClass, typeshell, NULL, ZERO);
  434.  
  435.   XtSetArg (args[ZERO], XtNallowVert, True);
  436.  
  437.   view = XtCreateManagedWidget ("typeview", viewportWidgetClass,
  438.                 frame, args, ONE);
  439.  
  440.   result =
  441.     MakeScrollList(view, "typeWindow", Type_items, doType, NULL, NULL);
  442.  
  443.   button = MakeCommandButton(frame, "None", doType,
  444.                  view, NULL, NULL);
  445.   return result;
  446. }
  447.  
  448. void
  449. MakeWaisCursors()
  450. {
  451.   int i;
  452.   XColor fore, back;
  453.   Pixmap cursor_pixmap, mask;
  454.  
  455.   back.red = 65535;
  456.   back.green = 65535;
  457.   back.blue = 65535;
  458.  
  459.   fore.red = 0;
  460.   fore.green = 0;
  461.   fore.blue = 0;
  462.  
  463.   mask = XCreateBitmapFromData(XtDisplay(top),
  464.                     XtScreen(top)->root,
  465.                     cursor_mask, cursor_width, cursor_height);
  466.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  467.                     XtScreen(top)->root,
  468.                     cursor0_bits, cursor_width, cursor_height);
  469.   wais_cursors[0] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  470.  
  471.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  472.                     XtScreen(top)->root,
  473.                     cursor1_bits, cursor_width, cursor_height);
  474.   wais_cursors[1] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  475.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  476.                     XtScreen(top)->root,
  477.                     cursor2_bits, cursor_width, cursor_height);
  478.   wais_cursors[2] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  479.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  480.                     XtScreen(top)->root,
  481.                     cursor3_bits, cursor_width, cursor_height);
  482.   wais_cursors[3] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  483.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  484.                     XtScreen(top)->root,
  485.                     cursor4_bits, cursor_width, cursor_height);
  486.   wais_cursors[4] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  487.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  488.                     XtScreen(top)->root,
  489.                     cursor5_bits, cursor_width, cursor_height);
  490.   wais_cursors[5] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  491.   cursor_pixmap = XCreateBitmapFromData(XtDisplay(top),
  492.                     XtScreen(top)->root,
  493.                     cursor6_bits, cursor_width, cursor_height);
  494.   wais_cursors[6] = XCreatePixmapCursor(CurDpy, cursor_pixmap, mask, &fore, &back, 0, 0);
  495. }
  496.  
  497. /*
  498.  *
  499.  * $Log: qdisplay.c,v $
  500.  * Revision 1.4  1995/01/10  17:06:47  pfeifer
  501.  * Better layout and colors?
  502.  *
  503.  * Revision 1.3  1994/12/23  16:43:07  pfeifer
  504.  * Change label to make layout correct
  505.  *
  506.  * Revision 1.2  1994/08/05  07:26:17  pfeifer
  507.  * Release beta 04
  508.  *
  509.  * Revision 1.1  1993/02/16  15:10:18  freewais
  510.  * Initial revision
  511.  *
  512.  * Revision 1.12  92/06/22  10:50:53  jonathan
  513.  * Put use of myAsciiSink and myAsciiSrc here.
  514.  * 
  515.  * Revision 1.11  92/06/15  13:50:53  jonathan
  516.  * Removed ShowKey button from text popups.
  517.  * 
  518.  * Revision 1.10  92/04/28  15:29:31  jonathan
  519.  * Cleaned up ANSI specs on most function calls.
  520.  * 
  521.  * Revision 1.9  92/03/23  16:11:59  jonathan
  522.  * added save requester.
  523.  * 
  524.  * Revision 1.8  92/03/17  14:16:40  jonathan
  525.  * Added cursor support.
  526.  * 
  527. */
  528.